package com.phz.springcloud.study.service;

import com.phz.springcloud.study.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

@Service
public class UserService {

	@Autowired
	private ApplicationContext context;

	/**
	 * 发布事件
	 * @param user
	 */
	public  void register(User user){
		System.out.println(user.getName() + "注册啦"+Thread.currentThread().getName());
		// 发送通知邮件
		context.publishEvent(new UserEvent(this,user));
	}


}
